CC = gcc
COMPILE_FLAG = -O0 -Wall 

SRC_DIRECTORY := src
BUILD_DIRECTORY := obj
INCLUDES := -I include 

LIBS = -lpthread

all: tcp_server_time tcp_client_time tcp_server_progress tcp_clinet_progress tcp_server_pthread tcp_clinet_pthread udp_server_time udp_clinet_time \
	 gethostbyname gethostent udp_clinet_time2 udp_broadcast_server udp_broadcast_client sock_fcntl sock_select sock_daemon sock_daemon2 \
	 sock_poll sock_epoll sock_epoll_et sock_multicast_client sock_multicast_server sock_ipc_stream_server sock_ipc_stream_clinet \
	 sock_ipc_dgram_client sock_ipc_dgram_server

tcp_server_time:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_server_time $(SRC_DIRECTORY)/tcp_server_time.c  $(LIBS)	

tcp_client_time:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_client_time $(SRC_DIRECTORY)/tcp_client_time.c  $(LIBS)

tcp_server_progress:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_server_progress \
				$(SRC_DIRECTORY)/msg.c	$(SRC_DIRECTORY)/tcp_server_progress.c  $(LIBS)

tcp_clinet_progress:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_clinet_progress \
				$(SRC_DIRECTORY)/msg.c	$(SRC_DIRECTORY)/tcp_clinet_progress.c  $(LIBS)

tcp_server_pthread:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_server_pthread \
				$(SRC_DIRECTORY)/msg.c	$(SRC_DIRECTORY)/tcp_server_pthread.c  $(LIBS)

tcp_clinet_pthread:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/tcp_clinet_pthread \
				$(SRC_DIRECTORY)/msg.c	$(SRC_DIRECTORY)/tcp_clinet_pthread.c  $(LIBS)

udp_server_time:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/udp_server_time $(SRC_DIRECTORY)/udp_server_time.c  $(LIBS) 

udp_clinet_time:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/udp_clinet_time $(SRC_DIRECTORY)/udp_clinet_time.c  $(LIBS) 

gethostbyname:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/gethostbyname $(SRC_DIRECTORY)/gethostbyname.c  $(LIBS)

gethostent:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/gethostent $(SRC_DIRECTORY)/gethostent.c  $(LIBS)

udp_clinet_time2:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/udp_clinet_time2 $(SRC_DIRECTORY)/udp_clinet_time2.c  $(LIBS)

udp_broadcast_server:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/udp_broadcast_server $(SRC_DIRECTORY)/udp_broadcast_server.c  $(LIBS)

udp_broadcast_client:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/udp_broadcast_client $(SRC_DIRECTORY)/udp_broadcast_client.c  $(LIBS)

sock_fcntl:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_fcntl \
				$(SRC_DIRECTORY)/sock_fcntl.c  $(SRC_DIRECTORY)/vector_fd.c $(LIBS)

sock_select:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_select \
				$(SRC_DIRECTORY)/sock_select.c  $(SRC_DIRECTORY)/vector_fd.c $(LIBS)

sock_daemon:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_daemon \
				$(SRC_DIRECTORY)/sock_daemon.c  $(SRC_DIRECTORY)/vector_fd.c $(LIBS)

sock_daemon2:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_daemon2 \
				$(SRC_DIRECTORY)/sock_daemon2.c  $(SRC_DIRECTORY)/vector_fd.c $(LIBS)

sock_poll:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_poll $(SRC_DIRECTORY)/sock_poll.c  -std=c99

sock_epoll:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_epoll $(SRC_DIRECTORY)/sock_epoll.c  -std=c99

sock_epoll_et:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_epoll_et $(SRC_DIRECTORY)/sock_epoll_et.c  -std=c99

sock_multicast_client:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_multicast_client $(SRC_DIRECTORY)/sock_multicast_client.c  -std=c99


sock_multicast_server:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_multicast_server $(SRC_DIRECTORY)/sock_multicast_server.c  -std=c99


sock_ipc_stream_server:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_ipc_stream_server $(SRC_DIRECTORY)/sock_ipc_stream_server.c  -std=c99

sock_ipc_stream_clinet:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_ipc_stream_clinet $(SRC_DIRECTORY)/sock_ipc_stream_clinet.c  -std=c99


sock_ipc_dgram_client:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_ipc_dgram_client $(SRC_DIRECTORY)/sock_ipc_dgram_client.c  -std=c99


sock_ipc_dgram_server:
	@test -d $(BUILD_DIRECTORY) || mkdir $(BUILD_DIRECTORY)
	$(CC) -g -rdynamic $(INCLUDES)   $(COMPILE_FLAG)  -o $(BUILD_DIRECTORY)/sock_ipc_dgram_server $(SRC_DIRECTORY)/sock_ipc_dgram_server.c  -std=c99

clean:
	rm -rf $(BUILD_DIRECTORY)/*